Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly clear NPCs in NPC tests #30031

Merged

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

The npc_can_target_player test was sometimes failing due to the hostile NPC choosing to target another NPC instead of the player.

This, in turn, was caused by the clearing of NPCs not being done properly. They were unloaded, but then loaded again, and not all were killed.

Describe the solution

Write a new clear_npcs in map_helpers.h which works more reliably, and call that instead.

Additional context

Not sure why this failure started appearing so much recently, but it's an inter-test dependency so it's always going to be somewhat unpredictable.

The npc_can_target_player test was sometimes failing due to the hostile
NPC choosing to target another NPC instead of the player.

This, in turn, was caused by the clearing of NPCs not being done
properly.  They were unloaded, but then loaded again, and not all were
killed.

Write a new clear_npcs in map_helpers.h which works more reliably, and
call that instead.
@kevingranade kevingranade merged commit 8533048 into CleverRaven:master Apr 28, 2019
@jbytheway jbytheway deleted the clear_npcs_properly_in_npc_tests branch April 28, 2019 21:24
jbytheway added a commit to jbytheway/Cataclysm-DDA that referenced this pull request Apr 29, 2019
clear_map had a similar flaw to the one fixed in CleverRaven#30031 affecting
npc_can_target_player.  Fix it in the same way.

This wasn't obviously affecting any tests, but it makes sense to fix it
pre-emptively.
kevingranade pushed a commit that referenced this pull request Apr 30, 2019
* Use clear_npcs in clear_map

clear_map had a similar flaw to the one fixed in #30031 affecting
npc_can_target_player.  Fix it in the same way.

This wasn't obviously affecting any tests, but it makes sense to fix it
pre-emptively.

* Before killing npcs, ensure correct ones loaded

Some tests
(default_overmap_generation_has_non_mandatory_specials_at_origin)
overwrite overmaps, which leads to orphaned NPCs.  Unloading and
reloading the NPCs ensures that all the active NPCs are known to the
overmap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants